package com.inifitness.admin.core.system.converter;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inifitness.admin.core.system.model.entity.SysConfig;
import com.inifitness.admin.core.system.model.form.ConfigForm;
import com.inifitness.admin.core.system.model.vo.ConfigPageVO;
import com.inifitness.common.model.Option;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 角色对象转换器
 *
 * @author sunjinfeng
 * @since 2022/5/29
 */
@Mapper(componentModel = "spring")
public interface ConfigConverter {

  @Mapping(target = "clazzLabel", expression = "java(com.inifitness.common.basic.BaseEnum.getLabelByValue(com.inifitness.common.enums.JavaTypeEnum.class,bo.getClazz()))")
  ConfigPageVO bo2Vo(SysConfig bo);

  Page<ConfigPageVO> entity2Page(Page<SysConfig> page);

  @Mapping(target = "value", source = "id")
  @Mapping(target = "label", source = "name")
  Option<Long> entity2Option(SysConfig config);

  List<Option<Long>> entities2Options(List<SysConfig> roles);

  SysConfig form2Entity(ConfigForm roleForm);

  ConfigForm entity2Form(SysConfig entity);
}